<?php
namespace Admin\Controller;
use Common\Controller\AdminbaseController;
class ConfigController extends AdminbaseController{
	
	

	
	function _initialize() {
		parent::_initialize();
		$this->db = D("Config");

		C("DEFAULT_FILTER","trim");
	}
	
	function index(){
		
	
		if (IS_POST) {
			
		$config=$_POST;
		//	dump($config);
	
	
		
			foreach ( $config as $key => $v ) {
				$data = array (
						'value' => $v,
						'name'=>$key
					
				);
				
				$this->db ->save($data);
			}
		
		$this->success("更新成功！");
		$this->db ->data_cache();
		
	
		
		
				
		} else {
		
		$group=I("get.group")?I("get.group"):"site";
		
		
			$map[group]=$group;
		
		$map[status]=1;
			//dump($group);
			$list   =  $this->db ->where($map)->select();
		
			foreach ($list as $key => $r) {
				$config[$r['name']] = $r;
			}
			//dump($site_config);
			$this->assign('CONFIG', $config);		
			
			
			$this->display($group);
				
		}
		
		
		
	}
	

	
	
	
}
